﻿
//订单推送
function GetOrderIdTuisong() {
    debugger;
    debugger;
    var orderid = Xrm.Page.data.entity.getId();
    var orgname = Xrm.Page.context.getOrgUniqueName();
    var entityame = Xrm.Page.data.entity.getEntityName();
    var ajaxurl = "https://crm.iskychem.com:444/iskyapp/tuisong.ashx?id=" + orderid + "&orgname=" + orgname + "&typename=" + entityame;

    $.ajax(
        {
            url: ajaxurl,
            type: "GET",
            cache: false,
            success: function (data) {
                if (data == "ok") {
                    if (window.parent) window.parent.location.reload(true);
                    else window.location.reload(true);
                }
                else if (data) {
                    alert(data);
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(errorThrown);
            }
        });
}


function GetOrderIdTuisongshoudong() {
    debugger;
    debugger;
    var orderid = Xrm.Page.data.entity.getId();
    var orgname = Xrm.Page.context.getOrgUniqueName();
    var entityame = Xrm.Page.data.entity.getEntityName();
    var ajaxurl = "https://crm.iskychem.com:444/iskyapp/tuisong.ashx?id=" + orderid + "&orgname=" + orgname + "&typename=" + entityame;

    $.ajax(
        {
            url: ajaxurl,
            type: "GET",
            cache: false,
            success: function (data) {
                if (data == "ok") {
                    if (window.parent) window.parent.location.reload(true);
                    else window.location.reload(true);
                }
                else if (data) {
                    alert(data);
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(errorThrown);
            }
        });
}



//报价利润推送
function GetRetransmitTuisong() {
    debugger;
    debugger;
    var ygcbid = Xrm.Page.data.entity.getId();
    var orgname = Xrm.Page.context.getOrgUniqueName();
    var entityame = Xrm.Page.data.entity.getEntityName();
    var ajaxurl = "https://crm.iskychem.com:444/ISV/Retransmit.ashx?id=" + ygcbid + "&orgname=" + orgname + "&typename=" + entityame;

    $.ajax(
       {
           url: ajaxurl,
           type: "GET",
           cache: false,
           success: function (data) {
               if (data == "ok") {
                   if (window.parent) window.parent.location.reload(true);
                    else window.location.reload(true);
                }
              else if (data) {
                   if (data.indexOf("插入重复键") > 0) {
                       alert('报价利润重复,无法传入!');
                   }
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
               alert(errorThrown);
           }
       });
}



function GetOrderIdTuisong1() {
    debugger;
    var status = Xrm.Page.getAttribute("new_status").getValue();
    if (status != 100000004) {
        Xrm.Utility.alertDialog("该状态下不允许生效, 请联系管理员！");
        return;
    }
    Xrm.Utility.confirmDialog("是否确定生效？", function () {
        Xrm.Page.getAttribute("new_status").setValue(100000001);
        //GetOrderIdTuisongshoudong();
        Xrm.Page.data.save();
    });

}